package com.servlet;

import com.dao.imp.AddChildType;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/11/22 22:13
 **/

@WebServlet(name = "AddChildTypeServlet", value = "/AddChildTypeServlet")
public class AddChildTypeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int parentId = Integer.parseInt(request.getParameter("parentId"));
        String categoryName = request.getParameter("categoryName");
        System.out.println(categoryName);

        String sql = "INSERT INTO onlineshop.childtype (child_type, parent_typeId) VALUES (\'" +
                categoryName+"\'," +
                parentId +
                ")";
        AddChildType addChildType = new AddChildType();
        addChildType.addGoodType(sql);
    }
}
